name: Check PR Title

on:
  pull_request:
    branches:
      - main
      - '**'

jobs:
  check-title:
    runs-on: ubuntu-latest
    steps:
        - name: Check PR Title
          uses: Slashgear/action-check-pr-title@v4.3.0
          with:
            regexp: '\[(ENH|BUG|DOC|TST|BLD|PERF|TYP|CLN|CHORE|RELEASE)\].*'
            helpMessage: "Please tag your PR title. See https://docs.trychroma.com/contributing#contributing-code-and-ideas. You must push new code to this PR for this check to run again."
        - name: Comment explaining failure
          if: failure()
          uses: actions/github-script@v6
          with:
            script: |
              github.rest.issues.createComment({
                issue_number: context.issue.number,
                owner: context.repo.owner,
                repo: context.repo.repo,
                body: 'Please tag your PR title with one of: \\[ENH | BUG | DOC | TST | BLD | PERF | TYP | CLN | CHORE\\]. See https://docs.trychroma.com/contributing#contributing-code-and-ideas'
              })
